/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * QuadroDeInformacoes.java
 *
 * Created on 13/07/2009, 14:32:00
 */
package interfaceGraficaUsuario;

import controle.Sistema;
import controle.UsuariosEnum;


/**
 *
 * @author João Paulo
 */
public class QuadroDeInformacoes extends javax.swing.JFrame {

    private String[] listaQuadro  = {"","","",""};
    private String avisos;
    private String plano;
    private String info;
    private String criterios;
    private final int AVISOS = 0;
    private final int PLANO = 1;
    private final int INFO = 2;
    private final int CRITERIOS = 3;
    private UsuariosEnum tipo;

    /** Creates new form QuadroDeInformacoes */
    public QuadroDeInformacoes() {
        initComponents();
        setTitle("Quadro de Informacoes");
        inicializa();
        setVisible(true);
        campoAvisos.setVisible(true);
        campoPlano.setVisible(true);
        campoInfo.setVisible(true);
        campoCriterios.setVisible(true);
        campoAvisos.setText(avisos);
        campoPlano.setText(plano);
        campoInfo.setText(info);
        campoCriterios.setText(criterios);
    }

    public QuadroDeInformacoes(UsuariosEnum tipo) {
        initComponents();
        inicializa();
        setVisible(true);
        this.tipo = tipo;
        campoAvisos.setVisible(true);
        campoPlano.setVisible(true);
        campoInfo.setVisible(true);
        campoCriterios.setVisible(true);
        campoAvisos.setText(avisos);
        campoPlano.setText(plano);
        campoInfo.setText(info);
        campoCriterios.setText(criterios);
        if (tipo == UsuariosEnum.ALUNO){
            campoAvisos.setEnabled(false);
            campoPlano.setEnabled(false);
            campoInfo.setEnabled(false);
            campoCriterios.setEnabled(false);
            botaoSalvar.setVisible(false);
        }else{
            campoAvisos.setEnabled(true);
            campoPlano.setEnabled(true);
            campoInfo.setEnabled(true);
            campoCriterios.setEnabled(true);
        }
    }
    public  void inicializa(){
        String[] quadroDeInformacoes = Sistema.getQuadroDeInformacoes();
        avisos = quadroDeInformacoes[AVISOS];
        plano = quadroDeInformacoes[PLANO];
        info = quadroDeInformacoes[INFO];
        criterios = quadroDeInformacoes[CRITERIOS];
    }

    public javax.swing.JTabbedPane getPainel() {
        return painelDeInformacoes;
    }

    public String[] criaLista(){
        avisos = campoAvisos.getText();
        plano = campoPlano.getText();
        info = campoInfo.getText();
        criterios = campoCriterios.getText();

        listaQuadro[AVISOS] = avisos;
        listaQuadro[PLANO] = plano;
        listaQuadro[INFO] = info;
        listaQuadro[CRITERIOS] = criterios;
        
        

        System.out.println(listaQuadro);
        
        return listaQuadro;
    }
    public void salvarTextos() {
        //criaLista();
        Sistema.salvaQuadroDeInformacoes(criaLista());


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelDeInformacoes = new javax.swing.JTabbedPane();
        painelAvisos = new javax.swing.JScrollPane();
        campoAvisos = new javax.swing.JTextArea();
        painelPlano = new javax.swing.JScrollPane();
        campoPlano = new javax.swing.JTextArea();
        painelCriterios = new javax.swing.JScrollPane();
        campoCriterios = new javax.swing.JTextPane();
        painelInfo = new javax.swing.JScrollPane();
        campoInfo = new javax.swing.JTextArea();
        botaoSalvar = new javax.swing.JButton();
        botaoSair = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(800, 600));

        painelDeInformacoes.setMinimumSize(new java.awt.Dimension(800, 600));

        campoAvisos.setColumns(20);
        campoAvisos.setRows(5);
        campoAvisos.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        campoAvisos.setSelectionColor(new java.awt.Color(0, 0, 0));
        painelAvisos.setViewportView(campoAvisos);

        painelDeInformacoes.addTab("Avisos", painelAvisos);

        campoPlano.setColumns(20);
        campoPlano.setRows(5);
        campoPlano.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        campoPlano.setSelectionColor(new java.awt.Color(0, 0, 0));
        painelPlano.setViewportView(campoPlano);

        painelDeInformacoes.addTab("Plano de Aula", painelPlano);

        campoCriterios.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        campoCriterios.setSelectionColor(new java.awt.Color(0, 0, 0));
        painelCriterios.setViewportView(campoCriterios);

        painelDeInformacoes.addTab("Critérios de Avaliação", painelCriterios);

        campoInfo.setColumns(20);
        campoInfo.setRows(5);
        campoInfo.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        campoInfo.setSelectionColor(new java.awt.Color(0, 0, 0));
        painelInfo.setViewportView(campoInfo);

        painelDeInformacoes.addTab("Informações do Projeto", painelInfo);

        botaoSalvar.setText("Salvar");
        botaoSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoSalvarActionPerformed(evt);
            }
        });

        botaoSair.setText("Sair");
        botaoSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoSairActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(painelDeInformacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 680, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(botaoSalvar)
                        .addGap(27, 27, 27)
                        .addComponent(botaoSair)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(painelDeInformacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 464, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoSair)
                    .addComponent(botaoSalvar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoSairActionPerformed
        dispose();
}//GEN-LAST:event_botaoSairActionPerformed

    private void botaoSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoSalvarActionPerformed
        salvarTextos();
}//GEN-LAST:event_botaoSalvarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new QuadroDeInformacoes().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoSair;
    private javax.swing.JButton botaoSalvar;
    private javax.swing.JTextArea campoAvisos;
    private javax.swing.JTextPane campoCriterios;
    private javax.swing.JTextArea campoInfo;
    private javax.swing.JTextArea campoPlano;
    private javax.swing.JScrollPane painelAvisos;
    private javax.swing.JScrollPane painelCriterios;
    private javax.swing.JTabbedPane painelDeInformacoes;
    private javax.swing.JScrollPane painelInfo;
    private javax.swing.JScrollPane painelPlano;
    // End of variables declaration//GEN-END:variables
}
